﻿Imports ATS.Business.Entities
Imports ATS.Data

Public Class CompanyDetailComponent

#Region "CRUD"
    Public Function CreateCompanyDetail(companyDetails As CompanyDetail) As CompanyDetail
        Return CreateNewCompany(companyDetails)
    End Function

    Public Function ReadCompanyDetail() As CompanyDetail
        Return ReadCompanyDetails()
    End Function

    Public Function UpdateCompanyDetail(companyDetails As CompanyDetail) As CompanyDetail
        Return UpdateCompanyDetails(companyDetails)
    End Function

#End Region

#Region "Support Procedures"
    Private Function CreateNewCompany(companyDetails As CompanyDetail) As CompanyDetail
        Dim dac As New AssetDataAccess()
        Try
            Return dac.CreateCompanyDetail(companyDetails)
        Catch ex As Exception
            Console.WriteLine(ex.Message)
            Throw ex
        End Try
    End Function

    Private Function ReadCompanyDetails() As CompanyDetail
        Dim dac As New AssetDataAccess()
        Try
            Return dac.ReadCompanyDetails()
        Catch ex As Exception
            Console.WriteLine(ex.Message)
            Throw ex
        End Try
    End Function

    Private Function UpdateCompanyDetails(companyDetails As CompanyDetail) As CompanyDetail
        Dim dac As New AssetDataAccess()
        Try
            dac.UpdateCompanyDetails(companyDetails)
            Return companyDetails
        Catch ex As Exception
            Console.WriteLine(ex.Message)
            Throw ex
        End Try
    End Function
#End Region
End Class
